/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "materialesxproveedor")
@NamedQueries({@NamedQuery(name = "Materialesxproveedor.findAll", query = "SELECT m FROM Materialesxproveedor m"), @NamedQuery(name = "Materialesxproveedor.findByIdmatxproveedor", query = "SELECT m FROM Materialesxproveedor m WHERE m.idmatxproveedor = :idmatxproveedor")})
public class Materialesxproveedor implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "idmatxproveedor")
    private Integer idmatxproveedor;
    @JoinColumn(name = "idMaterial", referencedColumnName = "idMaterial")
    @ManyToOne(optional = false)
    private Material idMaterial;
    @JoinColumn(name = "idProveedor", referencedColumnName = "idProveedor")
    @ManyToOne(optional = false)
    private Proveedor idProveedor;

    public Materialesxproveedor() {
    }

    public Materialesxproveedor(Integer idmatxproveedor) {
        this.idmatxproveedor = idmatxproveedor;
    }

    public Integer getIdmatxproveedor() {
        return idmatxproveedor;
    }

    public void setIdmatxproveedor(Integer idmatxproveedor) {
        Integer oldIdmatxproveedor = this.idmatxproveedor;
        this.idmatxproveedor = idmatxproveedor;
        changeSupport.firePropertyChange("idmatxproveedor", oldIdmatxproveedor, idmatxproveedor);
    }

    public Material getIdMaterial() {
        return idMaterial;
    }

    public void setIdMaterial(Material idMaterial) {
        Material oldIdMaterial = this.idMaterial;
        this.idMaterial = idMaterial;
        changeSupport.firePropertyChange("idMaterial", oldIdMaterial, idMaterial);
    }

    public Proveedor getIdProveedor() {
        return idProveedor;
    }

    public void setIdProveedor(Proveedor idProveedor) {
        Proveedor oldIdProveedor = this.idProveedor;
        this.idProveedor = idProveedor;
        changeSupport.firePropertyChange("idProveedor", oldIdProveedor, idProveedor);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmatxproveedor != null ? idmatxproveedor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Materialesxproveedor)) {
            return false;
        }
        Materialesxproveedor other = (Materialesxproveedor) object;
        if ((this.idmatxproveedor == null && other.idmatxproveedor != null) || (this.idmatxproveedor != null && !this.idmatxproveedor.equals(other.idmatxproveedor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return idMaterial.getNombre();
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
